package com.xjczjj.config.mybatis;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.springframework.stereotype.Component;

@Component
public class CommonMetaObjectHandler implements MetaObjectHandler {
    /**
     * 新增数据填充
     * @param metaObject
     */
    @Override
    public void insertFill(org.apache.ibatis.reflection.MetaObject metaObject)
    {
        /**
         * 参数1:元数据对象
         * 参数2:属性名称
         * 参数3:类对象
         * 参数4:当前系统时间
         */
        this.strictInsertFill(metaObject, "createTime", java.util.Date.class, new java.util.Date());
        this.strictInsertFill(metaObject, "updateTime", java.util.Date.class, new java.util.Date());
    }

    /**
     * 更新数据填充
     * @param metaObject
     */
    @Override
    public void updateFill(org.apache.ibatis.reflection.MetaObject metaObject)
    {
        this.setFieldValByName("updateTime", new java.util.Date(), metaObject);
    }
}
